<?php

//单一访问
//1 定义常量
define("ROOT_PATH", __DIR__ . "/../");
define("APP_PATH", ROOT_PATH . "app/");
define("C_PATH", APP_PATH . "controller/");
define("M_PATH", APP_PATH . "model/");
define("V_PATH", APP_PATH . "view/");
$config=
require_once(ROOT_PATH."config/config.php");
define("DB_TYPE", $config['dbtype']);
define("DB_HOST", $config['hostname']);
define("DB_NAME", $config['dbname']);
define("DB_USER", $config['username']);
define("DB_PASS", $config['password']);
spl_autoload_register(function($classname){
	$file=ROOT_PATH.$classname.".php";
	if (!is_file($file)) {
		exit($file . "文件不存在");
	}
	require_once ($file);
});
$arr=explode("/", $_SERVER["REQUEST_URI"]);
//1.处理请求过来的参数
//2.获取要请求的动作和控制器
$c = $arr["1"];
$a = $arr["2"];
$p = $arr["3"];
if (!$c||!$a) {
	$c=$config["defaultController"];
	$a=$config["defaultAction"];
	//访问默认的控制器和动作（User->index）
	echo "默认页面内容";
};
//引入对应PHP文件
$classname = "App\\Controller\\".ucfirst(strtolower($c)) . "Controller";
$obj = new $classname();
$obj -> $a($p ? $p : null);
?>